package cn.feizhu.aimarket.tools.config;


import cn.feizhu.aimarket.tools.*;
import jakarta.annotation.Resource;
import org.springframework.ai.support.ToolCallbacks;
import org.springframework.ai.tool.ToolCallback;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

/**
 * 对ai 工具几种注册，返回工具列表
 */
@Configuration
public class ToolRegistration {

    /*@Value("${google.serp.api-key}")
    private String googleSerpApiKey;*/

    @Value("${search.api-key}")
    private String searchApiKey;

    @Resource
    private FileOperationTool fileOperationTool;

    @Primary
    @Bean
    public ToolCallback[] allTools() {
        // 使用Spring注入的FileOperationTool Bean，而不是直接new
        WebScrapingTool webScrapingTool = new WebScrapingTool();
        ResourceDownloadTool resourceDownloadTool = new ResourceDownloadTool();

        return ToolCallbacks.from(
                fileOperationTool,
                webScrapingTool,
                resourceDownloadTool
        );
    }


}
